//
//  YYEIntrolCommandCell.m
//  YuYingEDU
//
//  Created by 胡波 on 2018/1/3.
//  Copyright © 2018年 胡波. All rights reserved.
//

#import "YYEIntrolCommandCell.h"

@interface YYEIntrolCommandCell ()

@property (nonatomic,strong) UIImageView *backIV;
@property (nonatomic,strong) UIImageView *headerIV;
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *timeLabel;
@property (nonatomic,strong) UILabel *introLabel;

@end

@implementation YYEIntrolCommandCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.contentView.backgroundColor = GeneralBackColor;
        
        self.backIV = [[UIImageView alloc]init];
        self.backIV.image = [UIImage imageNamed:@"noBorder"];
        [self.contentView addSubview:self.backIV];
        
        self.headerIV = [[UIImageView alloc]init];
        [self.backIV addSubview:self.headerIV];
        
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.font = [UIFont systemFontOfSize:14];
        self.nameLabel.textColor = [UIColor blackColor];
        [self.backIV addSubview:self.nameLabel];
        
        self.timeLabel = [[UILabel alloc]init];
        self.timeLabel.textColor = LineColor;
        self.timeLabel.textAlignment = NSTextAlignmentRight;
        self.timeLabel.font = [UIFont systemFontOfSize:12];
        [self.backIV addSubview:self.timeLabel];
        
        self.introLabel = [[UILabel alloc]init];
        self.introLabel.textColor = [UIColor blackColor];
        self.introLabel.font = [UIFont systemFontOfSize:13];
        self.introLabel.numberOfLines = 0;
        [self.backIV addSubview:self.introLabel];
        
//        self.nameLabel.text = @"陈晨";
//        self.timeLabel.text = @"2017.6.6";
//        self.introLabel.text = @"可以说这是一个很用心的视频教程了，几乎囊括了一个完整的前端开发流程，能够使我们少走很多弯路！！！";
        
    }
    return self;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.backIV makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(UIEdgeInsetsMake(0.5, 8, 0, 8));
    }];
    
    [self.headerIV makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.backIV.left).offset(16);
        make.top.equalTo(self.backIV.top).offset(18);
        make.size.equalTo(CGSizeMake(20, 20));
    }];
    
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerIV.right).offset(10);
        make.centerY.equalTo(self.headerIV.centerY);
    }];
    
    [self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.backIV.right).offset(-10);
        make.centerY.equalTo(self.headerIV.centerY);
    }];
    
    [self.introLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.backIV.left).offset(10);
        make.right.equalTo(self.backIV.right).offset(-10);
//        make.bottom.equalTo(self.backIV.bottom).offset(-10);
        make.top.equalTo(self.headerIV.bottom).offset(7);
    }];
    
}

- (void)setCommandModel:(YYELessonCommandModel *)commandModel {
    _commandModel = commandModel;
    
    [self.headerIV sd_setImageWithURL:[NSURL URLWithString:commandModel.img]];
    self.nameLabel.text = commandModel.name;
    self.timeLabel.text = commandModel.com_create_at;
    self.introLabel.text = commandModel.comment;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
